/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package montecarlo.main;

import java.util.ArrayList;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import montecarlo.gui.mainFrame;
import montecarlo.math.montecarlo;

/**
 *
 * @author F101520
 */
public class Main
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                mainFrame ex = new mainFrame();
                ex.setVisible(true);
            }
        });


        int nbThread = 32;
        double tPercent;
        double[] percents = new double[nbThread];
        long time1, time2;
        time1 = System.currentTimeMillis();
        montecarlo mt = new montecarlo("c", 40, 50, 0.5, 0.06, 0.10, 0.45, 168, 800000);
        //System.out.println(mt.monteCarloSingle());
        time2 = System.currentTimeMillis();
        System.out.println((time2 - time1));

        System.out.println("This is madness !!!!\n");

        time1 = System.currentTimeMillis();
        mt.monteCarloMulti(nbThread);
        while (mt.getMtHolder().getNbFinished() != nbThread)
        {
            tPercent = 0;
            try
            {
                for (int i = 0; i < nbThread; i++)
                {
                    percents[i] = mt.getMtHolder().getPercent(i);
                    tPercent += percents[i];
                }
                System.out.println("Threads " + tPercent / nbThread + "%");
                Thread.sleep(500);
            } catch (InterruptedException ex)
            {
            }
        }

        time2 = System.currentTimeMillis();
        System.out.println((time2 - time1));
        System.out.println(mt.getMtHolder().getFinaleSum());


    }
}
